<?php

/**
 * 评论
 *
 * Created by PhpStorm.
 * User: evan
 * Date: 16/9/7
 * Time: 上午2:50
 */
class Comment extends MY_Api_Controller
{
    /**
     * 评论列表
     */
    public function index()
    {
        $module  = (int)$this->input->get_post('by_module');
        $bid     = (int)$this->input->get_post('bid');
        $uid     = $this->uid;
        $page   = (int)$this->input->get_post('page');
        $limit  = (int)$this->input->get_post('limit');


        $this->load->service('common/service_common_comment');
        $data = $this->service_common_comment->index($module, $bid, $uid, $page, $limit);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 提交评论
     */
    public function submit()
    {
        $module  = (int)$this->input->get_post('by_module');
        $bid     = (int)$this->input->get_post('bid');
        $uid     = $this->uid;
        $content = trim($this->input->get_post('content'));


        $param = array
        (
            'module'  => $module,
            'bid'     => $bid,
            'uid'     => $uid,
            'content' => $content,
        );


        $this->load->service('common/service_common_comment');
        $data = $this->service_common_comment->submit($param);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 回复评论
     */
    public function reply()
    {
        $cid = (int)$this->input->get_post('cid');
        $uid = $this->uid;
        $content = trim($this->input->get_post('content'));


        $this->load->service('common/service_common_comment');
        $data = $this->service_common_comment->reply($cid, $uid, $content);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 反馈(支持|反对)
     */
    public function feedback()
    {
        $cid  = (int)$this->input->get_post('cid');
        $type = (int)$this->input->get_post('type');


        $this->load->service('common/service_common_comment');
        $data = $this->service_common_comment->feedback($cid, $type);


        $this->json_output($data['data'], $data['status']);
    }
}